package com.wholesale.beans;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class UploadOrderResponse {
	private String orderSn;
	private String reason;
	private int returnCode;
	private List<CorrectGoodsPrice> correctGoodsPriceLst;
	private JSONObject jsonObject;

	public List<CorrectGoodsPrice> getCorrectGoodsPriceLst() {
		return correctGoodsPriceLst;
	}

	public void setCorrectGoodsPriceLst(
			List<CorrectGoodsPrice> correctGoodsPriceLst) {
		this.correctGoodsPriceLst = correctGoodsPriceLst;
	}

	public String getOrderSn() {
		return orderSn;
	}

	public void setOrderSn(String orderSn) {
		this.orderSn = orderSn;
	}

	public String getReason() {
		return reason;
	}

	public void setReason(String reason) {
		this.reason = reason;
	}

	public int getReturnCode() {
		return returnCode;
	}

	public void setReturnCode(int returnCode) {
		this.returnCode = returnCode;
	}

	public void jsonAnalytic(String jsonString) {

		try {
			jsonObject = new JSONObject(jsonString);
			jsonAnalytic(jsonObject);
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public void jsonAnalytic(JSONObject jsonObject) {
		this.jsonObject = jsonObject;

		try {
			orderSn = jsonObject.getString("orderSn");
		} catch (JSONException e) {
			e.printStackTrace();
		}
		try {
			reason = jsonObject.getString("reason");
		} catch (JSONException e) {
			e.printStackTrace();
		}
		try {
			returnCode = jsonObject.getInt("returnCode");
		} catch (JSONException e) {
			e.printStackTrace();
		}

		try {
			JSONArray lst = jsonObject.getJSONArray("correctGoodsPriceLst");
			correctGoodsPriceLst = new ArrayList<CorrectGoodsPrice>();
			int size = lst.length();
			for (int i = 0; i < size; i++) {
				CorrectGoodsPrice cgp = new CorrectGoodsPrice();
				cgp.jsonAnalytic(lst.getJSONObject(i));
				correctGoodsPriceLst.add(cgp);
			}
		} catch (JSONException e) {
			e.printStackTrace();
		}

	}
}
